
{

    const NAME = 'services.login'
    const CONFIG = require(__MAIN__ + '/config.ts')
    const FNS = require(__LIBS__ + '/functions.ts')
    module.exports = require('angular')
        .module(NAME, [])
        .factory('login', ($http) => {
            return {
                getUserData: function () {
                    return $http.jsonp(CONFIG.urlGetUserData + '?callback=JSON_CALLBACK')
                },
                userLogin: function (userData) {
                    userData = angular.extend({
                        uname: '',
                        password: '',
                        forward: '/',
                        rememberAccount: false,
                        rememberPassword: false,
                        autoRedirecting: true
                    }, userData)
                    return $http.jsonp(CONFIG.urlUserLogin + '?callback=JSON_CALLBACK' + FNS.urlEncode(userData))
                },
                userLogout: function () {
                    return $http.jsonp(CONFIG.urlUserLogout + '?callback=JSON_CALLBACK')
                },
                checkRole: function (sid) {
                    return $http.jsonp(CONFIG.urlCheckRole + '?callback=JSON_CALLBACK&sid=' + sid)
                }
            }
        })

}